<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><{:C('site_name')}></title>
<meta name="keywords" content="<{:C('keyword')}>" />
<meta name="description" content="<{:C('content')}>" />
<link rel="stylesheet" href="<{:STATICS}>/css/bootstrap.min.css" type="text/css" media="all" />
<link rel="stylesheet" href="<{:RES}>/css/admin.css" type="text/css"/>
<link rel="stylesheet" href="<{:STATICS}>/uploadify/uploadify.css" type="text/css"/>
</head>
<script type="text/javascript" src="<{:STATICS}>/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<{:STATICS}>/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<{:STATICS}>/js/jquery.artDialog.js?skin=aero"></script>
<script type="text/javascript" src="<{:STATICS}>/js/iframeTools.js"></script>
<style>
body,ul,li{ margin: 0px; padding: 0px;}
.list {
	clear:both; overflow:hidden; padding:0 10px 10px 10px;}
.list label{
	width:160px; float:left; line-height:24px; height:24px; margin-right:10px; font-size:12px; overflow: hidden;}
.list label input,.first label input{
	vertical-align: text-bottom;
}
</style>
<body>


<div class="list">
<volist name="list" id="vo">
<label title="<{$vo.text}>"><input type="checkbox" name="hy" value="<{$vo.val}>" > <span><{$vo.text}></span> </label>
</volist>
</div>

<p style="padding-left:10px;"><input type="button" class="btn btn-success" value="确定" onclick="returnHomepage()" /></p>

<script type="text/javascript">

var domid=art.dialog.data('domid');
var origin = artDialog.open.origin;
var dom = origin.document.getElementById(domid);
var domsrcid=domid+'_str';

oldstr = dom.value;

if(oldstr!=''){
	oldArr = oldstr.split(",");
	$(".list input[name='hy']").each(function(){
		for (var i = 0; i < oldArr.length; i++) {
		    if (oldArr[i].indexOf($(this).val()) > -1) {
		    	$(this).attr("checked",true);
		    }
		};
  	});
}

// 返回数据到主页面
function returnHomepage(){
	backStr = '';
	i=0;
	$("input[name='hy']:checked").each(function(){
		backStr += '<li><span>'+$(this).val()+'</span><strong>&times;</strong><input type="hidden" name="tag[]" value="'+$(this).val()+'" /></li>';	
		if (i==0) {
			backVal = $(this).val();
		}else{
			backVal +=','+$(this).val();
		}
		i=1;
  	});

  	if(backStr==''){
  		alert('至少要选择一项');
  		return false;
  	}	


  	dom.value = backVal;
  	origin.document.getElementById(domsrcid).innerHTML = backStr;
	setTimeout("art.dialog.close()", 100 )
}

$(function(){
	$(".list input[name='hy']").click(function(){
		if ($(".list input[name='hy']:checked").length > 5 ) {
	        $(this).attr("checked",false);
	        alert("最多能选5个");
	    }
	})
})
</script>
</body>
</html>
